public class Text1 {
    //
        public int reverse(int x) {
            int a = 0;
            while(x != 0){
                if (a < Integer.MIN_VALUE / 10 || a > Integer.MAX_VALUE / 10) {
                    return 0;
                }

                int d = x % 10;
                x/=10;
                x = x * 10 + d;
            }
            return a;
        }
}
